package com.linshuo.employee.service.impl;

import com.linshuo.employee.entity.Salary;
import com.linshuo.employee.repository.SalaryRepository;
import com.linshuo.employee.service.SalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class SalaryServiceImpl implements SalaryService {
    @Autowired
    private SalaryRepository salaryRepository;

    @Override
    public Salary saveSalary(Salary salary) {
        return salaryRepository.save(salary);
    }

    @Override
    public Salary updateSalary(Salary salary) {
        return salaryRepository.save(salary);
    }

    @Override
    public void deleteSalary(Long id) {
        salaryRepository.deleteById(id);
    }

    @Override
    public Salary getSalaryById(Long id) {
        Optional<Salary> salary = salaryRepository.findById(id);
        return salary.orElse(null);
    }

    @Override
    public List<Salary> getAllSalaries() {
        return salaryRepository.findAll();
    }
} 